import React, { useState, useEffect,useRef } from 'react';
import axios from 'axios';
import './css/bg_gzt_qb.css'

function Rw() {
    const listHeight=useRef()
    console.log(listHeight.current)   

  const [data, setData] = useState([]);
  useEffect(() => {
    const fetchData = async () => {
      const result = await axios.post(
        'http://crm.cimns.com/index.php/oa/index/index',{
            type:4,
            page:1,
            limit:15
        }
      );
      console.log(result.data);
      setData(result.data.data.list);
    };
    fetchData();
    
     
  }, []);
  for (let i = 0; i < data.length; i++) {
    if (data[i].create_user_info.img === '') {
      data[i].create_user_info.img = 'http://img3.hefei.cc/day_120417/20120417_eceb3191217a6e6d9f008vdg9Rl64W1g.jpg'
    }
    if (data[i].type_name === '日程'||data[i].type_name === '任务') {
      
    }
  };


   var a = true
    var scrollTop = document.documentElement.scrollTop;
    var windowHeight = document.documentElement.clientHeight;
    var scrollHeight = document.documentElement.scrollHeight;
    console.log(scrollTop+windowHeight);
    if(scrollTop+windowHeight+50>scrollHeight&&a){
        a=false
        var sz = 0
        console.log(document.documentElement.listHeightHeight);
        console.log('000000000000000000000');
        
    }
  


  return (
    <div ref={listHeight}>
      {data.map((item,index) => (
        <div key={index} className= 'for' id='for'>
          <div><img src={item.create_user_info.img} alt='理员'/></div>
          <div className='clearfix'>
            <div className='clearfix pp'>
              <p>{item.create_user_info.realname}<span>{item.content}</span></p>
              <p>
                <img alt='0' src=''/>
                {item.type_name}
                </p>
            </div>
            <span className='span'>{item.create_time}</span>
            <div className='vv'><a>{item.title}</a></div>
          </div>
        </div>
      ))}
    </div>
  );
}
export default Rw
